package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import com.sun.xml.internal.bind.v2.runtime.RuntimeUtil.ToStringAdapter;

import play.data.validation.Required;
import play.db.jpa.Model;

@Entity
public class Fonction extends Model{
	
	@Required
	@Column(unique=true)
	public String id_fonction;
	
	@Required
	public String nom;
	
	@ManyToMany(cascade=CascadeType.ALL, mappedBy="fonction")
	public List<Agent> agent;
	
	public Fonction(String nom){
		this.nom=nom;
		agent=new ArrayList<Agent>();
	}
	
	public String toString(){
		return nom;
	}
}
